home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / DISSOL32.ZIP / DSLVEXP.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-31  |  5.2 KB  |  165 lines

  1. VERSION 4.00
  2. Begin VB.Form Disolve1 
  3.    Caption         =   "Bitmap Dissolve Experiment"
  4.    ClientHeight    =   4710
  5.    ClientLeft      =   1050
  6.    ClientTop       =   1590
  7.    ClientWidth     =   8205
  8.    DrawMode        =   9  'Not Mask Pen
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   0
  12.       weight          =   700
  13.       size            =   8.25
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    Height          =   5160
  19.    Left            =   990
  20.    LinkTopic       =   "Form1"
  21.    ScaleHeight     =   314
  22.    ScaleMode       =   3  'Pixel
  23.    ScaleWidth      =   547
  24.    Top             =   1200
  25.    Width           =   8325
  26.    Begin VB.CommandButton DissolveButton 
  27.       Caption         =   "Do Dissolve"
  28.       Height          =   432
  29.       Left            =   3240
  30.       TabIndex        =   2
  31.       Top             =   4140
  32.       Width           =   1632
  33.    End
  34.    Begin VB.PictureBox Picture2 
  35.       Height          =   3912
  36.       Left            =   4260
  37.       Picture         =   "dslvexp.frx":0000
  38.       ScaleHeight     =   257
  39.       ScaleMode       =   3  'Pixel
  40.       ScaleWidth      =   253
  41.       TabIndex        =   1
  42.       Top             =   120
  43.       Width           =   3852
  44.    End
  45.    Begin VB.PictureBox Picture1 
  46.       AutoRedraw      =   -1  'True
  47.       Height          =   3912
  48.       Left            =   120
  49.       Picture         =   "dslvexp.frx":9682
  50.       ScaleHeight     =   257
  51.       ScaleMode       =   3  'Pixel
  52.       ScaleWidth      =   253
  53.       TabIndex        =   0
  54.       Top             =   120
  55.       Visible         =   0   'False
  56.       Width           =   3852
  57.    End
  58.    Begin VB.Timer Timer1 
  59.       Enabled         =   0   'False
  60.       Interval        =   56
  61.       Left            =   3120
  62.       Top             =   2640
  63.    End
  64. Attribute VB_Name = "Disolve1"
  65. Attribute VB_Creatable = False
  66. Attribute VB_Exposed = False
  67. Option Explicit
  68. Dim hBrush As Variant
  69. Dim PixelSetSequence(64) As Integer
  70. Dim DissolveStep As Integer
  71. Const NumberOfSteps = 8
  72. Private Function CreateDissolveBrush(DissolveStep As Integer) As Integer
  73. Dim hCompBitmap As Long
  74. Dim BrushBitmapInfo As BITMAPINFO
  75. Dim Counter As Integer
  76. Dim PixelData As String * 32
  77. Dim Dummy As Long
  78. Dim Row As Integer
  79. Dim Column As Integer
  80.    With BrushBitmapInfo.bmiHeader
  81.       .biSize = 40
  82.       .biWidth = 8
  83.       .biHeight = 8
  84.       .biPlanes = 1
  85.       .biBitCount = 1
  86.       .biCompression = 0
  87.       .biSizeImage = 0
  88.       .biXPelsPerMeter = 0
  89.       .biYPelsPerMeter = 0
  90.       .biClrUsed = 0
  91.       .biClrImportant = 0
  92.    End With
  93.    ' Set the color table values for
  94.    ' the brush to black and white.
  95.    With BrushBitmapInfo.bmiColors(0)
  96.       .rgbBlue = 0
  97.       .rgbGreen = 0
  98.       .rgbRed = 0
  99.       .rgbReserved = 0
  100.    End With
  101.    With BrushBitmapInfo.bmiColors(1)
  102.       .rgbBlue = 255
  103.       .rgbGreen = 255
  104.       .rgbRed = 255
  105.       .rgbReserved = 0
  106.    End With
  107.    ' Initialize brush bitmap pixel data to all white.
  108.    For Counter = 0 To 7
  109.       Mid$(PixelData, Counter * 4 + 1, 1) = Chr$(&HFF)
  110.    Next Counter
  111.    ' Set the bits representing the black pixels to 0.
  112.    For Counter = 1 To DissolveStep * (64 / NumberOfSteps)
  113.       Row = (PixelSetSequence(Counter) - 1) \ 8
  114.       Column = (PixelSetSequence(Counter) - 1) Mod 8
  115.       Mid$(PixelData, Row * 4 + 1, 1) = Chr$(Asc(Mid$(PixelData, Row * 4 + 1, 1)) And (Not (2 ^ Column)))
  116.    Next Counter
  117.    '  Convert the DIB into a DDB and create the pattern brush.
  118.    hCompBitmap = CreateDIBitmap(Disolve1.hDC, BrushBitmapInfo.bmiHeader, CBM_INIT, PixelData, BrushBitmapInfo, DIB_RGB_COLORS)
  119.    CreateDissolveBrush = CreatePatternBrush(hCompBitmap)
  120.    Dummy = DeleteObject(hCompBitmap)
  121. End Function
  122. Private Sub CreatePixelSetSequence()
  123. Dim Counter As Integer
  124. Dim PixelNumberString As String * 5
  125. Const PixelListFile = 1
  126.    Open App.Path & "\PixelLst.TXT" For Input As #PixelListFile
  127.    For Counter = 1 To 64
  128.       Input #PixelListFile, PixelNumberString
  129.       PixelSetSequence(Counter) = Val(PixelNumberString)
  130.    Next Counter
  131. End Sub
  132. Private Sub DissolveButton_Click()
  133.    DissolveButton.Enabled = False
  134.    Timer1.Enabled = True
  135. End Sub
  136. Private Sub Form_Load()
  137.    CreatePixelSetSequence
  138.    DissolveStep = 0
  139. End Sub
  140. Private Sub Picture2_Click()
  141.    If DissolveStep < NumberOfSteps Then
  142.       DissolveStep = DissolveStep + 1
  143.       Picture2_Paint
  144.    End If
  145. End Sub
  146. Private Sub Picture2_Paint()
  147. Dim hRgn As Long
  148. Dim Dummy As Long
  149. Dim hOldBrush As Long
  150.    hBrush = CreateDissolveBrush(DissolveStep)
  151.    hOldBrush = SelectObject(Picture2.hDC, hBrush)
  152.    Dummy = BitBlt(Picture2.hDC, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hDC, 0, 0, &HAC0744)
  153.    'Dummy = StretchBlt%(Picture2.hDC, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hDC, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, &HAC0744)
  154.    Dummy = SelectObject(Picture2.hDC, hOldBrush)
  155.    Dummy = DeleteObject(hBrush)
  156. End Sub
  157. Private Sub Timer1_Timer()
  158.    If DissolveStep < NumberOfSteps Then
  159.       DissolveStep = DissolveStep + 1
  160.       Picture2_Paint
  161.    Else
  162.       Timer1.Enabled = False
  163.    End If
  164. End Sub
  165.